home *** CD-ROM | disk | FTP | other *** search
- Path: sun001.spd.dsccc.com!spd!jmccarty
- From: jmccarty@spd.dsccc.com (Mike McCarty)
- Newsgroups: comp.lang.c
- Subject: Re: C constant expression declarations
- Date: 16 Feb 1996 19:56:26 GMT
- Organization: DSC Communications Corporation, Plano, Texas USA
- Message-ID: <4g2nha$ksa@sun001.spd.dsccc.com>
- References: <31229735.41C67EA6@isi.com> <4fvl5cINN94q@keats.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: aplo139.spd.dsccc.com
-
- In article <4fvl5cINN94q@keats.ugrad.cs.ubc.ca>,
- Kazimir Kylheku <c2a192@ugrad.cs.ubc.ca> wrote:
- )In article <31229735.41C67EA6@isi.com>, J.R. Stoner <jstoner@isi.com> wrote:
- )>This is a query (I have checked the FAQ) into something that strikes me
- )>as a dumbfoundedly stupid issue, but I will ask it anyway :)
- )>
- )>Normally, I will do things such as:
- )>
- )> #define EXPR1 1
- )> #define EXPR2 2
- )>
- )>...and so on. Lately, I have been observing in code from other people
- )>equivalent declarations such as:
- )>
- )> #define EXPR1 (1)
- )> #define EXPR2 (2)
- )
- )This does not buy you anything at all, since the thing you are bracketing
- )has only one constituent: it's not a compound expression.
-
- I respectfully disagree with this statement. It buys two very important
- things, to wit:
-
- it builds a good habit of putting parens in, so that when they
- are needed they don't inadvertently get left out
-
- it builds consistency, so that one gets a feeling that
- "something may be wrong here" when inspecting code for
- errors
-
- I believe that (for the sake of creating and maintaining correct
- programs) these are well worth the extra discipline (at first) and
- compilation time for the cases where the parens are not strictly needed.
-
- Mike
- ----
- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
-
- I don't speak for DSC. <- They make me say that.
-